from faker import Faker
import json
from config.settings import BASE_DIR

# 初始化Faker
fake = Faker("zh_CN")


# 生成测试数据
def generate_warehouse_data():
    # 生成唯一的仓库名称（避免重复）
    warehouse_name = f"仓库_{fake.company_suffix()}_{fake.random_int(100, 999)}"
    # 生成联系电话
    contact_phone = fake.phone_number()
    # 生成备注信息
    remark = f"备注_{fake.word()}"

    return {
        "warehouse_name": warehouse_name,
        "contact_phone": contact_phone,
        "update_remark": f"修改_{remark}"
    }


# 生成多组数据并写入JSON
if __name__ == "__main__":
    # 创建datas目录（如果不存在）
    # os.makedirs(os.path.dirname(__file__), exist_ok=True)
    # 生成3组测试数据
    test_datas = [generate_warehouse_data() for _ in range(3)]
    json_file_path = BASE_DIR / "datas" / "basic_data" / "warehouse.json"
    # 写入JSON文件
    with open(json_file_path, "w", encoding="utf-8") as f:
        json.dump(test_datas, f, ensure_ascii=False, indent=2)
